// 实现一个 observe 和 一个 observable

let observerSet = new Set();
// observable
let handler = {
    set(target,prop,value,receiver) {

        let isOk = Reflect.set(target,prop,value,receiver);
        observerSet.forEach(observer => observer(prop));
        return isOk;
    }
}

let observable = (obj) => {
    return new Proxy(obj,handler);
}

//  observe
let observe = (fun) => observerSet.add(fun);



let obj = {
    name:'daxia',
    age:13
}
function logProp(key) {
    console.log('设置',key,'中');
}
observe(logProp);
let objProxy = observable(obj);

objProxy.name = 'xiaye';
objProxy.age = 16;

console.log(objProxy);